#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll T, n, m, l, V, d[300005], v[300005], a[300005], p[300005];
int main(){
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> T;
    for(ll j = 1; j <= T; j++){
        cin >> n >> m >> l >> V;
        for(ll i = 1; i <= n; i++) cin >> d[i] >> v[i] >> a[i];
        for(ll i = 1; i <= m; i++) cin >> p[i];
        ll pl = p[m], sum = 0;
        double sv = 0;
        for(ll i = 1; i <= n; i++){
            if(pl - d[i] < 0) continue;
            sv = sqrt(v[i] * v[i] + 2 * a[i] * (pl - d[i]));
            if(sv > V) sum++;
        }
        cout << sum << " " << m - 1 << '\n';
    }
    return 0;
}
